package io.renren.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.sys.entity.CarOrderinfo;
import io.renren.modules.sys.entity.Carmanage;
import io.renren.modules.sys.dao.CarmanageMapper;
import io.renren.modules.sys.service.CarmanageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author beisheng
 * @since 2022-09-05
 */
@Service
public class CarmanageServiceImpl extends ServiceImpl<CarmanageMapper, Carmanage> implements CarmanageService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String root = (String) params.get("root");
        String test = (String) params.get("test");
        QueryWrapper<Carmanage> queryWrapper = new QueryWrapper<>();
        if (root!=null && root!=""){
            queryWrapper.like(StringUtils.isNotBlank(root),"car_name", root).or().like("car_code",root);
        }
        if (test!=null && test!=""){
            queryWrapper.like(StringUtils.isNotBlank(test),"car_name", test);
        }
        IPage<Carmanage> page = this.page(new Query<Carmanage>().getPage(params), queryWrapper);
        return new PageUtils(page);
    }

    @Override
    public List<Carmanage> findAllCarRand() {
        return baseMapper.findAllCarRand();
    }
}
